int rte_waypt_ct; /* # waypoints in waypoint list */
} route_head;
+/*
+ * Bounding box information.
+ */
+typedef struct {
+ double max_lat;
+ double max_lon;
+ double min_lat;
+ double min_lon;
+} bounds;
+
typedef void (*ff_init) (char const *);
typedef void (*ff_deinit) (void);
typedef void (*ff_read) (void);
void waypt_del (waypoint *);
void waypt_free (waypoint *);
void waypt_disp_all(waypt_cb);
+void waypt_compute_bounds(bounds *);
void waypt_flush(queue *);
void waypt_flush_all(void);
unsigned int waypt_count(void);
static const char *gpx_version;
static const char *gpx_creator;
+static char *xsi_schema_loc;
static char *gpx_email = NULL;
static char *gpx_author = NULL;
#define MYNAME "GPX"
#define MY_CBUF 4096
+#define DEFAULT_XSI_SCHEMA_LOC "http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"
+
typedef enum {
tt_unknown = 0,
tt_gpx,
else if (strcmp(avp[0], "src") == 0) {
gpx_creator = avp[1];
}
+ else if (strcmp(avp[0], "xsi:schemaLocation") == 0) {
+ if (0 == strstr(xsi_schema_loc, avp[1])) {
+ xsi_schema_loc = xstrappend(xsi_schema_loc, " ");
+ xsi_schema_loc = xstrappend(xsi_schema_loc, avp[1]);
+ }
+ }
avp+=2;
}
}
cdatastr = vmem_alloc(1, 0);
*((char *)cdatastr.mem) = '\0';
+ xsi_schema_loc = xstrdup(DEFAULT_XSI_SCHEMA_LOC);
+
XML_SetElementHandler(psr, gpx_start, gpx_end);
XML_SetCharacterDataHandler(psr, gpx_cdata);
}
{
time_t now = 0;
int short_length;
+ bounds bounds;
time( &now );
fprintf(ofd, "creator=\"GPSBabel - http://gpsbabel.sourceforge.net\"\n");
fprintf(ofd, "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
fprintf(ofd, "xmlns=\"http://www.topografix.com/GPX/1/0\"\n");
- fprintf(ofd, "xsi:schemaLocation=\"http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\">\n");
+ fprintf(ofd, "xsi:schemaLocation=\"%s\">\n", xsi_schema_loc ? xsi_schema_loc : DEFAULT_XSI_SCHEMA_LOC);
gpx_write_time( now, "time" );
-
+ waypt_compute_bounds(&bounds);
+ fprintf(ofd, "<bounds minlat=\"%f\" minlon =\"%f\" "
+ "maxlat=\"%f\" maxlon=\"%f\" />\n",
+ bounds.min_lat, bounds.min_lon,
+ bounds.max_lat, bounds.max_lon);
waypt_disp_all(gpx_waypt_pr);
gpx_track_pr();
gpx_route_pr();